package com.cldz.service;

import com.cldz.common.dto.res.FsuChannelResDto;
import com.cldz.dao.FsuChannelMapper;
import com.cldz.utils.BeanCopyUtil;
import com.cldz.common.dto.req.FsuChannelDto;
import com.cldz.entity.FsuChannel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @ Author     ：lixiao.
 * @ Date       ：Created in 16:16 2018/12/21
 * @ Description：
 * @ Modified By：
 */
@Service("fsuChannelService")
public class FsuChannelService {

    @Autowired
    private FsuChannelMapper fsuChannelMapper;

    public List<FsuChannelResDto> getFsuRegulatChannel(FsuChannelDto fsuChannelDto){
        List<FsuChannel> fsuRegulatChannel = fsuChannelMapper.getFsuRegulatChannel(fsuChannelDto);
        return copyListBean(fsuRegulatChannel);
    }

    public List<FsuChannelResDto> getFsuControlChannel(FsuChannelDto fsuChannelDto){
        List<FsuChannel> fsuRegulatChannel = fsuChannelMapper.getFsuControlChannel(fsuChannelDto);
        return copyListBean(fsuRegulatChannel);
    }


    private List<FsuChannelResDto> copyListBean(List<FsuChannel> devListByTypeID) {
        List<FsuChannelResDto> list = new ArrayList<>();
        for (FsuChannel device : devListByTypeID) {
            FsuChannelResDto dto = new FsuChannelResDto();
            BeanCopyUtil.copyPropertiesIgnoreNull(device, dto);
//            BeanUtils.copyProperties(device, dto);
            list.add(dto);
        }
        return list;
    }
}
